﻿using CTTest.Common;
using CTTest.Essential.Soap.Shell;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace CTTest.Essential
{
    class PaiUtil
    {
        public static bool TestChangeNumber(ChangeNumberRequestVO req, WriteLogger log)
        {
            Assert.IsNotNull(req, "ChangeNumberRequestVO req");
            Assert.IsNotNull(log, "WriteLogger log");

            using (PaiServiceSoapImplService sc = new PaiServiceSoapImplService())
            {
                log("Begin to invoke soap method {0}\r\n{1}", sc.Url, TestUtil.WrapperObject(req));

                var e = sc.changeNumber(req);

                log("Finish to invoke soap method {0}\r\n{1}", sc.Url, TestUtil.WrapperObject(e));
                return e.resultCode == 0;
            }
        }
        public static bool TestChangeUserFeatures(ChangeUserFeaturesRequestVO req, WriteLogger log)
        {
            Assert.IsNotNull(req, "ChangeUserFeaturesRequestVO req");
            Assert.IsNotNull(log, "WriteLogger log");

            using (PaiServiceSoapImplService sc = new PaiServiceSoapImplService())
            {
                log("Begin to invoke soap method {0}\r\n{1}", sc.Url, TestUtil.WrapperObject(req));

                var e = sc.changeUserFeatures(req);

                log("Finish to invoke soap method {0}\r\n{1}", sc.Url, TestUtil.WrapperObject(e));
                return e.resultCode == 0;
            }
        }
        public static bool TestChangeUserState(ChangeUserStateRequestVO req, WriteLogger log)
        {
            Assert.IsNotNull(req, "ChangeUserStateRequestVO req");
            Assert.IsNotNull(log, "WriteLogger log");

            using (PaiServiceSoapImplService sc = new PaiServiceSoapImplService())
            {
                log("Begin to invoke soap method {0}\r\n{1}", sc.Url, TestUtil.WrapperObject(req));

                var e = sc.changeUserState(req);

                log("Finish to invoke soap method {0}\r\n{1}", sc.Url, TestUtil.WrapperObject(e));
                return e.resultCode == 0;
            }
        }
        public static bool TestCreateUser(CreateUserRequestVO req, WriteLogger log)
        {
            Assert.IsNotNull(req, "CreateUserRequestVO req");
            Assert.IsNotNull(log, "WriteLogger log");

            using (PaiServiceSoapImplService sc = new PaiServiceSoapImplService())
            {
                log("Begin to invoke soap method {0}\r\n{1}", sc.Url, TestUtil.WrapperObject(req));

                var e = sc.createUser(req);

                log("Finish to invoke soap method {0}\r\n{1}", sc.Url, TestUtil.WrapperObject(e));
                return e.resultCode == 0;
            }
        }
        public static bool TestDeleteUser(DeleteUserRequestVO req, WriteLogger log)
        {
            Assert.IsNotNull(req, "DeleteUserRequestVO req");
            Assert.IsNotNull(log, "WriteLogger log");

            using (PaiServiceSoapImplService sc = new PaiServiceSoapImplService())
            {
                log("Begin to invoke soap method {0}\r\n{1}", sc.Url, TestUtil.WrapperObject(req));

                var e = sc.deleteUser(req);

                log("Finish to invoke soap method {0}\r\n{1}", sc.Url, TestUtil.WrapperObject(e));
                return e.resultCode == 0;
            }
        }
    }
}
